ref(node): Streamline vendored fs instrumentation#21532
Conversation
This streamlines the vendored `fs` instrumentation, following the same approach as the dataloader (#21475) and generic-pool (#21523) refactors: * Use `Sentry.startSpan`/`startInactiveSpan`/`suppressTracing` instead of the OTel tracer APIs * Use the built-in `onlyIfParent` option instead of `requireParentSpan` + a hand-rolled parent check * Remove the unused `createHook`/`endHook`/`requireParentSpan` config and inline the span name, `op`/`origin` and file-path/error attributes directly into the instrumentation * Streamline the types to what we actually need * Remove the `/* eslint-disable */` and make the vendored files pass the (type-aware) linter * Add tests covering the previously-untested option gating While inlining the attribute logic, this also fixes a pre-existing bug: the documented `recordFilePaths` option was never read — file-path span attributes were gated on `recordErrorMessagesAsSpanAttributes` instead. File paths are now gated on `recordFilePaths` and error messages on `recordErrorMessagesAsSpanAttributes`, matching the docs. Closes #20726 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
c02973a to
5754444
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5754444. Configure here.
| const result = await runner.makeRequest('get', '/readFile'); | ||
| expect(result).toEqual('done'); | ||
| await runner.completed(); | ||
| }); |
There was a problem hiding this comment.
Option gating tests omit absence checks
Medium Severity
The new recordFilePaths / recordErrorMessagesAsSpanAttributes integration tests assert span data with expect.objectContaining only. They never assert that the gated attribute is absent, so a regression that records both path_argument and fs_error when only one option is enabled would still pass.
Triggered by project rule: PR Review Guidelines for Cursor Bot
Reviewed by Cursor Bugbot for commit 5754444. Configure here.


Summary
This streamlines the vendored
fsinstrumentation, following the same approach as the dataloader (#21475) and generic-pool (#21523) refactors:Sentry.startSpan/startInactiveSpan/suppressTracinginstead of the OTel tracer APIsonlyIfParentoption instead ofrequireParentSpan+ a hand-rolled parent checkcreateHook/endHook/requireParentSpanconfig and inline the span name,op/originand file-path/error attributes directly into the instrumentation/* eslint-disable */and make the vendored files pass the (type-aware) lintercontext.bindfrom@opentelemetry/apiis kept only for the callback-style functions, where the user's async callback must be restored to the parent context (so it isn't parented to the fs span or caught by tracing suppression) — there is no Sentry equivalent for this.Root cause (drive-by bug fix)
While inlining the attribute logic, this also fixes a pre-existing bug: the documented
recordFilePathsoption was never read — file-path span attributes (path_argument,src_argument, etc.) were gated onrecordErrorMessagesAsSpanAttributesinstead (dates back to the original integration in #13291).File paths are now gated on
recordFilePathsand error messages onrecordErrorMessagesAsSpanAttributes, matching the documented options. New integration tests cover each gate in isolation.Closes #20726